import time
from selenium import webdriver
class Login:
    def __init__(self):
        self.wd=webdriver.Chrome()
        self.wd.get('http://192.168.13.45:8080/woniusales')
        self.wd.implicitly_wait(30)

    def do_login(self,username,pwd):
        self.wd.find_element_by_id('username').clear()
        self.wd.find_element_by_id('username').send_keys(username)
        self.wd.find_element_by_id('password').clear()
        self.wd.find_element_by_id('password').send_keys(pwd)
        self.wd.find_element_by_id('verifycode').clear()
        self.wd.find_element_by_id('verifycode').send_keys('0000')
        self.wd.find_element_by_xpath('//button[@onclick="doLogin(\'null\')"]').click()
        time.sleep(1)
        t=self.wd.find_element_by_link_text('注销').text
        if t == '注销':
            print('登录成功')
        else:
            print('登录失败')


if __name__ == '__main__':
    Login().do_login('admin','admin123')

